using Circus.CodeEditor;
using Circus.CodeEditor.Serialization;
using Circus.Syntax.Lexer;
using System;
using System.ComponentModel;
using System.Drawing;
namespace Circus.CodeEditor.Dialogs
{
	public class ColorTheme :  IDisposable
	{
		private string name = string.Empty;
		private bool readOnly = false;
		private Font font = new Font(FontFamily.GenericMonospace.Name, 10f, FontStyle.Regular);
		private LexStyles lexStyles = new LexStyles(null);
		public virtual string Name
		{
			get
			{
				return this.name;
			}
			set
			{
				if (this.name != value)
				{
					this.name = value;
					this.OnNameChanged();
				}
			}
		}
		public virtual bool ReadOnly
		{
			get
			{
				return this.readOnly;
			}
			set
			{
				if (this.readOnly != value)
				{
					this.readOnly = value;
					this.OnReadonlyChanged();
				}
			}
		}
		public virtual Font Font
		{
			get
			{
				return this.font;
			}
			set
			{
				if (this.font != value)
				{
					this.font = value;
					this.OnFontChanged();
				}
			}
		}
		public virtual LexStyles LexStyles
		{
			get
			{
				return this.lexStyles;
			}
			set
			{
				this.lexStyles.Clear();
				foreach (LexStyle current in value)
				{
					LexStyle lexStyle = new LexStyle(null);
					lexStyle.Assign(current);
					this.lexStyles.Add(lexStyle);
				}
			}
		}
		public LexStyle this[string name]
		{
			get
			{
				return this.lexStyles.FindLexStyle(name);
			}
		}
		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

		protected virtual void OnNameChanged()
		{
		}
		protected virtual void OnReadonlyChanged()
		{
		}
		protected virtual void OnFontChanged()
		{
		}
		protected virtual void OnLexStylesChanged()
		{
		}
		public ColorTheme()
		{
		}
		public ColorTheme(string name, bool readOnly, Font Font, LexStyles lexStyles)
		{
			this.name = name;
			this.readOnly = readOnly;
			this.font = Font;
			this.LexStyles = lexStyles;
		}
		~ColorTheme()
		{
			this.Dispose(false);
		}
		protected virtual void Dispose(bool disposing)
		{
			if (disposing)
			{
				if (this.font != null)
				{
					this.font.Dispose();
					this.font = null;
				}
			}
		}
		public void Dispose()
		{
			this.Dispose(true);
			GC.SuppressFinalize(this);
		}
	}
}
